package cn.haocxy.jfm.util;


/**
 * 判断操作系统类型，最初只考虑支持Linux和Windows，
 * 因为我只有这两种操作系统，
 * 并且不细分，不支持的类型统一为Other。
 * @author 蔡心宇
 *
 */
public final class OS {

	private OS() {
	}
	
	public static final int Other = 0;
	public static final int Linux = 1;
	public static final int Windows = 2;
	
	private static final int type;
	
	static {
		String prop = System.getProperty("os.name");
		type = getType(prop);
	}
	
	private static int getType(String prop) {
		if (prop == null) {
			return Other;
		}
		
		prop = prop.toLowerCase();
		if (prop.contains("windows")) { 
			return Windows;
		}
		if (prop.contains("linux")) {
			return Linux;
		}
		
		return Other;
	}
	
	public static int type() {
		return type;
	}
	
	public static boolean isWin32() {
		return type == Windows;
	}

	public static boolean isLinux() {
		return type == Linux;
	}
}
